<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AbleButton</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        :root {
            --border-color: #e0e0e0;
            --button-gray: #e0e0e0;
            --button-hover-gray: #bdbdbd;
            --dark-blue: #1a237e;
            --dark-red: #b71c1c;
            --hover-blue: #283593;
            --hover-red: #c62828;
            --light-gray: #f5f5f5;
        }

        body {
            margin: 0;
            padding: 0;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            display: flex;
            flex-direction: column;
            height: 100vh;
            background-color: #f8f9fa;
        }

        .header {
            background-color: var(--dark-blue);
            color: white;
            padding: 10px;
            text-align: center;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

        .header h1 {
            margin: 0;
            font-size: 1.2em;
        }

        .api-status {
            font-size: 0.8em;
            margin-top: 5px;
            color: #ffc107;
        }

        .messages-container {
            flex: 1;
            overflow-y: auto;
            padding: 20px;
            padding-bottom: 120px;
            background-color: #f8f9fa;
        }

        .message {
            margin-bottom: 10px;
            max-width: 85%;
            border: 1px solid var(--border-color);
            border-radius: 8px;
            overflow: hidden;
            position: relative;
            transition: all 0.3s ease;
        }

        .user-message {
            background-color: var(--light-gray);
            padding: 12px;
            margin: 8px 0;
            border-radius: 8px;
            align-self: flex-end;
            margin-left: auto;
            margin-right: 10px;
        }

        .user-message .user-content {
            color: #000;
            white-space: pre-wrap;
            margin: 0;
        }

        .ai-message {
            background-color: white;
            padding: 12px 12px 16px 16px;
            margin: 8px 0;
            border-radius: 8px;
            margin-left: 10px;
            margin-right: auto;
            position: relative;
            border-left: 4px solid transparent;
        }

        .search-message {
            border-left: 4px solid var(--dark-red);
            position: relative;
        }

        .bottom-container {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            background: white;
            border-top: 1px solid var(--border-color);
            box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
        }

        .toolbar {
            display: flex;
            justify-content: space-between;
            padding: 10px;
            background-color: white;
            border-bottom: 1px solid var(--border-color);
        }

        .toolbar-left {
            flex: 1;
        }

        .toolbar-right {
            display: flex;
            gap: 8px;
        }

        .tool-button {
            padding: 8px 15px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 5px;
            font-size: 0.9em;
            transition: all 0.2s ease;
            min-width: 80px;
            justify-content: center;
            background-color: var(--button-gray);
            color: #333;
        }

        .tool-button:hover {
            background-color: var(--button-hover-gray);
        }

        .tool-button.active {
            background-color: var(--dark-blue);
            color: white;
        }

        #selectAreaBtn,
        #downloadBtn,
        #settingsBtn {
            background-color: var(--button-gray);
            color: #333;
        }

        #selectAreaBtn:not(.active),
        #downloadBtn:not(.active),
        #settingsBtn:not(.active) {
            background-color: var(--button-gray);
            color: #333;
        }

        .input-container {
            display: flex;
            gap: 8px;
            padding: 10px;
            background: white;
            border-top: 1px solid var(--border-color);
        }

        #messageInput {
            flex: 1;
            min-height: 40px;
            max-height: 120px;
            padding: 8px 12px;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            resize: none;
            overflow-y: auto;
            font-size: 14px;
            line-height: 1.5;
            box-sizing: border-box;
        }

        #messageInput:focus {
            outline: none;
            border-color: var(--dark-blue);
            box-shadow: 0 0 0 2px rgba(26,35,126,0.1);
        }

        #sendButton {
            width: 56px;
            padding: 8px;
            background: var(--dark-blue);
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
            font-size: 14px;
            height: 40px;
            box-sizing: border-box;
        }

        #sendButton:hover {
            background: var(--hover-blue);
        }

        #searchToggle {
            min-width: 240px;
        }

        .markdown-body {
            font-size: 0.95em;
            line-height: 1.5;
            position: relative;
            transition: opacity 0.3s ease;
        }

        .markdown-body h3, .markdown-body h4, .markdown-body h5 {
            margin-top: 1em;
            margin-bottom: 0.5em;
        }

        .markdown-body p {
            margin-top: 0.5em;
            margin-bottom: 0.5em;
        }

        .markdown-body ul {
            margin: 4px 0;
            padding-left: 20px;
        }

        .markdown-body li {
            margin: 2px 0;
            line-height: 1.4;
        }

        .markdown-body pre {
            background-color: #f6f8fa;
            padding: 10px;
            border-radius: 4px;
            overflow-x: auto;
            margin: 0.5em 0;
        }

        .markdown-body code {
            font-family: monospace;
            background-color: #f6f8fa;
            padding: 2px 4px;
            border-radius: 3px;
        }

        .error-message {
            background-color: #fff3f3;
            border: 1px solid #dc3545;
            color: #dc3545;
            border-left: 4px solid #f44336;
        }

        #operationStatus {
            position: fixed;
            top: 10px;
            right: 10px;
            padding: 8px 12px;
            background: rgba(0, 0, 0, 0.8);
            color: white;
            border-radius: 4px;
            z-index: 1000;
            display: none;
        }

        /* 状态文本样式 */
        .status-text {
            display: block;
            font-size: 14px;
            color: #666;
            margin-bottom: 4px;
        }

        /* 进度条容器 */
        .progress-container {
            position: absolute;
            left: 0;
            bottom: 0;
            width: 100%;
            height: 4px;
            background-color: #eef2f7;
            overflow: hidden;
            border-bottom-left-radius: 8px;
            border-bottom-right-radius: 8px;
        }

        /* 进度条 */
        .progress-bar {
            height: 100%;
            width: 0;
            background: linear-gradient(90deg, 
                var(--dark-blue) 0%,
                #4a90e2 25%,
                #ffffff 50%,
                #4a90e2 75%,
                var(--dark-blue) 100%
            );
            background-size: 200% 100%;
            transition: width 0.6s ease;
            animation: shimmer 2s infinite linear;
            position: relative;
            overflow: hidden;
        }

        .progress-bar::after {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 50%;
            height: 100%;
            background: linear-gradient(
                90deg,
                transparent 0%,
                rgba(255, 255, 255, 0.3) 50%,
                transparent 100%
            );
            animation: flowLight 1.5s infinite ease-in-out;
        }

        @keyframes flowLight {
            0% { left: -100%; }
            100% { left: 200%; }
        }

        @keyframes shimmer {
            0% { background-position: 200% 0; }
            100% { background-position: -200% 0; }
        }

        /* 完成状态的进度条效果 */
        .search-message.completed .progress-bar {
            background: linear-gradient(90deg, #4CAF50, #8BC34A);
            animation: completedShimmer 1.5s infinite linear;
        }

        @keyframes completedShimmer {
            0% { opacity: 0.8; }
            50% { opacity: 1; }
            100% { opacity: 0.8; }
        }

        /* 移除旧的思考动画相关样式 */
        .thinking {
            position: relative;
        }

        .thinking::after {
            display: none; /* 隐藏右侧圆圈 */
        }

        .markdown-body.thinking {
            opacity: 0.7;
        }

        /* 完成状态样式 */
        .search-message.completed .progress-container {
            opacity: 0;
            transition: opacity 0.3s ease;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>AbleButton</h1>
        <div id="apiStatus" class="api-status">正在连接...</div>
    </div>
    <div id="chatMessages" class="messages-container"></div>
    <div class="bottom-container">
        <div class="toolbar">
            <div class="toolbar-left">
                <button id="searchToggle" class="tool-button primary">
                    普通对话
                </button>
            </div>
            <div class="toolbar-right">
                <button id="selectAreaButton" class="tool-button">
                    <i class="fas fa-crop-alt"></i>框选区域
                </button>
                <button id="downloadButton" class="tool-button">
                    <i class="fas fa-download"></i>下载文件
                </button>
                <button id="settingsButton" class="tool-button">
                    <i class="fas fa-cog"></i>设置
                </button>
            </div>
        </div>
        <div class="input-container">
            <textarea id="messageInput" placeholder="输入搜索内容..." rows="1"></textarea>
            <button id="sendButton">
                发送
            </button>
        </div>
    </div>
    <div id="operationStatus"></div>
    <script type="module" src="sidepanel.js"></script>
</body>
</html> 